//
//  CZAccount.m
//  CZOC微博01
//
//  Created by 1 on 15/12/2.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "CZAccount.h"
/*
 返回值字段	字段类型	字段说明
 access_token	string	用于调用access_token，接口获取授权后的access token。
 expires_in	string	access_token的生命周期，单位是秒数。
 remind_in	string	access_token的生命周期（该参数即将废弃，开发者请使用expires_in）。
 uid	string	当前授权用户的UID。
 

 
 */
@implementation CZAccount
+ (instancetype)accountWithDic:(NSDictionary *)dict
{
    CZAccount *account=[[CZAccount alloc]init];
    account.access_token=dict[@"access_token"];
    account.expires_in=dict[@"expires_in"];
    account.uid=dict[@"uid"];
    return account;
}
//归档的时候

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.access_token forKey:@"access_token"];
    [aCoder encodeObject:self.expires_in forKey:@"expires_in"];
    [aCoder encodeObject:self.uid forKey:@"uid"];
    [aCoder encodeObject:self.create_time forKey:@"create_time"];
}
//解档
//- (id)initWithCoder:(NSCoder *)aDecoder
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
     if(self=[super init])
     {
         self.access_token=[aDecoder decodeObjectForKey:@"access_token"];
          self.expires_in=[aDecoder decodeObjectForKey:@"expires_in"];
          self.uid=[aDecoder decodeObjectForKey:@"uid"];
         self.create_time=[aDecoder decodeObjectForKey:@"create_time"];
     }
    return self;
}
@end
